/**
 Copyright (C) 2013 Yuyao Liang

 This source code is release under the BSD License.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.

 Created on Oct 29, 2013 10:02:11 PM
 */
package com.googlecode.backtest.rule.criteria;

import java.util.List;
import java.util.UUID;

import org.joda.time.LocalDate;

import com.googlecode.backtest.dataset.manager.DataReadyEvent;
import com.googlecode.backtest.dataset.manager.IDataManager;
import com.googlecode.backtest.rule.IBackTestParameters;
import com.googlecode.backtest.rule.action.BackTestActions;
import com.googlecode.backtest.rule.action.IBackTestActions;

/**
 * 
 * @author lianyuy
 * 
 */
public abstract class BackTestCriteria implements
		IBackTestCriteria<IBackTestActions, IBackTestParameters> {
	protected IBackTestActions actions = new BackTestActions();
	protected List<String> data_ids;
	protected double[] values = null;
	protected LocalDate[] dates = null;
	protected String _ID;
	protected IBackTestParameters parameter;
	protected IDataManager manager = null;

	public BackTestCriteria(String id, List<String> data_ids,
			IBackTestParameters parameter) {
		this();
		this.data_ids = data_ids;
		this._ID = id;
		this.parameter = parameter;
	}

	public BackTestCriteria() {
		super();
		Long uuid = UUID.randomUUID().getMostSignificantBits();
		_ID = Long.toHexString(uuid);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.GUIDable#getGUID()
	 */
	@Override
	public String getGUID() {
		return _ID;
	}

	/**
	 * @return the actions
	 */
	protected IBackTestActions getActions() {
		return actions;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IAlgorithm#getResult()
	 */
	@Override
	public IBackTestActions getResult() {
		return actions;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.googlecode.backtest.dataset.manager.DataReadyEventListener#OnDataReady
	 * (com.googlecode.backtest.dataset.manager.DataReadyEvent)
	 */
	@Override
	public void OnDataReady(DataReadyEvent event) {
		if (manager == null) {
			manager = event.getManager();
		}
	}

}
